using System;
using W32 = Microsoft.Win32;

namespace AMFC
{
	/// <summary>
	/// Summary description for AFCRegistry.
	/// </summary>
	public class Registry{
		private static string ReadValue(string valueName){return ReadValue(valueName,null);}
		private static string ReadValue(string valueName,object valueDefault){
			W32.RegistryKey subKey = W32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\AMFC",true);
			object val = subKey.GetValue(valueName);
			if( val == null )
				if( valueDefault != null ){
					subKey.SetValue(valueName,valueDefault);
					return (string)valueDefault;
				}else
					throw new ApplicationException("Key '"+valueName+"' has not been found in Registry.");
			return val.ToString();
		}
//		private static string ReadValue(string valueName,object def){return Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wealthcorp\Connections").GetValue(valueName,def).ToString();}

		public static string imagePath{get{return ReadValue("imagePath",@"\\AFCDEV\Fax");}}

		public static string dbServer{get{return ReadValue("DB_Server","AFCDATA");}}
		public static string dbCatalog{get{return ReadValue("DB_Catalog","AFC");}}
		public static string dbUserName{get{return ReadValue("DBUserName");}}
		public static string dbPassword{get{return ReadValue("DBPassword");}}

		public static string adsRoot{get{return ReadValue("ADS_Root");}}
		public static string adsUser{get{return ReadValue("ADS_User","");}}
		public static string adsPassword{get{return ReadValue("ADS_Password","");}}
		public static string domain{get{return ReadValue("Domain");}}

		public static string mining_Usr{get{return ReadValue("Mining_Usr","btoc");}}
		public static string mining_Pwd{get{return ReadValue("Mining_Pwd","btoc11");}}
		public static string mining_Folder{get{return ReadValue("Mining_Folder");}}
		public static string mining_Share{get{return ReadValue("Mining_Share");}}
		public static string mining_Server{get{return ReadValue("Mining_Server");}}
		public static string mining_Database{get{return ReadValue("mining_Database");}}

		public static string dbConnection{get{return ReadValue("DB_Connection");}}
		public static string dbConnectionADO{get{return ReadValue("DB_Connection_ADO");}}

		public static string mailErrorTo{get{return ReadValue("Mail_ErrorTo","dimokhot@hotmail.com");}}
		public static string mailErrorFrom{get{return ReadValue("Mail_ErrorFrom","Error@AMFC");}}

		public static string faxServer{get{return ReadValue("FAX_Server","\\\\devnet");}}
	}
}
